<template>
	<u-modal :show="show" showCancelButton :title="`确定${formData.type === 1 ? '通过' : '驳回'}审核?`" @cancel="cancel" @confirm="confirm">
    <view style="width: 100%;">

      <u-form :model="formData" labelPosition="top" :labelWidth="100">
        <u-form-item v-if="formData.type === 1" label="医生签名" prop="desc" borderBottom required :customStyle="{'flex-direction': 'row'}">
					<image v-if="info.prescriptionSign" :src="info.prescriptionSign" style="width:200rpx;height:auto;" mode="widthFix" />
          <u-button v-else type="primary" size="small" @click="goSetUp">去设置签名</u-button>
        </u-form-item>
        <u-form-item label="审核备注" prop="desc" :required="formData.type === 2">
          <u-textarea v-model="formData.remark" placeholder="请输入审核备注, 驳回审核时必填"></u-textarea>
        </u-form-item>
      </u-form>
    </view>
	</u-modal>
</template>

<script>
import expApi from '@/api/expertIdentity.js'

export default {
  props: {
    info: {
      type: Object,
      default: () => {},
    }
  },
	data() {
		return {
			show: false,
      formData: {
        id: null,
        type: 1, // 1: 审核通过, 2:审核驳回
        remark: ''
      }
		};
	},
	methods: {
		async open(type) {
			this.show = true;
      this.formData.type = type;
		},
    // 去设置签名
    goSetUp() {
      this.goPage(`/expertIdentity/prescription/signature`)
    },
    confirm() {
      if(this.formData.type === 2 && !this.formData.remark){
        uni.showToast({
          title: '请输入审核备注',
          icon: 'none'
        })
        return
      }
      this.formData.id = this.info.id;
      console.log(this.formData);
      expApi.approveOrder(this.formData).then(()=>{
        this.cancel();
        this.$emit('refresh');
        uni.showToast({
          title: '审核成功',
          icon: 'none'
        })
      })
    },
    cancel() {
			this.show = false;
    }
	},
};
</script>

<style lang="scss" scoped></style>
